// 引入axios
import axios from "axios";
// 引入进度条
import NProgress from "nprogress";
// 引入样式
import "nprogress/nprogress.css";
let request = axios.create({
  baseURL: "/api",
  timeout:50000
});
// 请求拦截器
request.interceptors.request.use(
  config => {
    // 进度
    NProgress.start();
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);
// 响应拦截器
request.interceptors.response.use(
  response => {
    NProgress.done();
    return response.data;
  },
  error => {
    return Promise.reject(error);
  }
);

export default request;
